package com.rs.service.impl.rs;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.rs.dao.ReimbursetypeMapper;
import com.rs.model.CommonResult;
import com.rs.model.Reimbursetype;
import com.rs.service.rs.RecipientsTypeService;

@Service
public class RecipientsTypeServiceImpl implements RecipientsTypeService {

	@Autowired
	private ReimbursetypeMapper rem;

	@Override
	public int addReimbursetype(Reimbursetype rt) {

		return rem.insert(rt);
	}

	@Override
	public CommonResult<Map<String, Object>> selectAll(Reimbursetype reimbursetype) {

		Page<Reimbursetype> page = PageHelper.startPage(reimbursetype.getPageNum(), 10);
		List<Reimbursetype> list = rem.selectAll();
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("list", list);
		map.put("total", page.getTotal());
		map.put("pageNum", page.getPageNum());
		map.put("pages", page.getPages());
		return new CommonResult<Map<String, Object>>(200, "查询成功", map);

	}

	@Override
	public int delect(Integer valueOf) {

		return rem.deleteByPrimaryKey(valueOf);
	}

	@Override
	public int update(Reimbursetype reimbursetype) {

		return rem.updateByPrimaryKey(reimbursetype);
	}

	@Override
	public Reimbursetype selecyOne(Integer n_id) {

		return rem.selectByPrimaryKey(n_id);
	}

}
